<template>
  <div id="m7head">
    <!-- 原密码没输入提示 -->
    <div id="m7hint">
      <div id="m7hint1">
        <h3>温馨提示</h3>
        <p class="m7hint-two">原密码不能为空，请重新输入!</p>
        <p id="m7hint-three" >关闭</p>
      </div>
    </div>

    <div class="m7page">
      <div class="m7head">
      <router-link to="Enroll"><img src="../assets/img/箭头.png" alt="" width="20px" height="20px" /> </router-link>  
        <span>重置登录密码</span>
      </div>
      <!-- 账户重新设置密码 -->
      <div class="m7account">
        <ul>
          <li>
            <p>手机号</p>
            <p style="font-size: 18px" id="m7phone">  <input type="text" v-model="phon" placeholder="请输入电话号码"></p>
          </li>
          <li>
            <p>新密码</p>
            <input
              type="text"
              placeholder="请输入新密码"
              v-model="m7newCo"
            />
          </li>
          <li>
            <p>确认密码</p>
            <input
              type="text"
              placeholder="请再次输入密码"
              v-model="m7newCodeTwo"
            />
          </li>
          <!-- <li>
                <p>手机号码</p>
                <p style="font-size: 18px;" id="phone">152****1511</p>
            </li> -->
          <li>
            <div class="m7verificationCode">
              <div class="m7a1">
                <p>短信验证码</p>
                <input
                  type="text"
                  placeholder="请输入6位验证码"
                  v-model="m7sixx"
                />
              </div>
              <div id="gain" v-if="codeShow" @click="getPhoneCode">
                获取验证码
              </div>
              <span v-if="!codeShow" class="count">{{ count }}秒后重试</span>
            </div>
          </li>
        </ul>
      </div>

      <button id="m7confirm" @click="qd">确定</button>
    </div>
  </div>
</template>
<script>
import { Dialog } from 'vant';
 import {tese,resee }  from "../api/resetLogin"
export default {
  data() {
    return {
      codeShow: true,
      count: "",
      timer: null,
      phon:this.$route.params.phone,
      m7newCo:"",
      m7newCodeTwo:"",
      m7sixx:""
    };
  },
  created() {
   
   
  },
  methods: { 
    sendMsg(){
        tese({phone:this.phon}).then((res)=>{
            console.log(res)
    })
},
    qd(){
          if(this.phon==""||this.m7newCo==""||this.m7newCodeTwo==""||this.m7sixx==""){
            Dialog({title: '温馨提示', message: '输入不能为空' });
            return;
          }
          if(this.m7newCo!=this.m7newCodeTwo){
            Dialog({title: '温馨提示', message: '密码不一致,请重新输入' });
            return;
          }
          if(this.m7newCo==this.m7newCodeTwo &&this.phon==""||this.m7newCo==""){
            Dialog({title: '温馨提示', message: '输入不能为空，请重新输入' });
            return;
          }
        let t={ 
            phone:this.phon,
            password:this.m7newCo,
            repassword:this.m7newCodeTwo,
            code:this.m7sixx
        }
        resee(t).then((res)=>{
              if(res.code==200){
                console.log(111);
                 this.$router.push({
                  name:'win'
                 })
              }else{

                Dialog({title: '温馨提示', message: res.msg });
              }
            
        })
    },
 

    getPhoneCode() {
      //获取短信验证码
      // 正则验证b
      const TIME_COUNT = 60;
      if (!this.timer) {
        this.count = TIME_COUNT;
        this.codeShow = false;
        this.timer = setInterval(() => {
          if (this.count > 0 && this.count <= TIME_COUNT) {
            this.count--;
          } else {
            this.codeShow = true;
            clearInterval(this.timer);
            this.timer = null;
          }
        }, 1000);
      }
      let code = {
        mobile: this.mobile,
        sms_type: "login",
      };
      this.sendMsg();
    
      
   
    },
  },
};
</script>


<style scoped src="../assets/css/resetLogin.css" >
</style>